#include<stdio.h>
long filesize( FILE *fp)//declare this function and its return value is long sign
{
	
	long cur_pos,length;//input two long integer variables cur_pos and length
	cur_pos = ftell(fp);//to represent the current position of file pointer in the stream
	fseek(fp,0,SEEK_END);//represent the file pointer in the stream to the end of the file
	length=ftell(fp);//use ftell to find the interval between the start and current position of fp
	fseek(fp,cur_pos,SEEK_SET);//using fseek to let the fp reposition to the origin position
	return length;//return to length of file
}
void main(int argc, char *argv[])//main function with no return value
{
	FILE *fp;//initialize the file pointer
	char   Name[20];//create an new array to input a short name of file
	fp=fopen("text.txt","rb");//calculate the length of file"text.txt"
	fgets(Name,20,fp);
	printf("file length is %ld.\n",filesize(fp));//output the length of the file
	fgets(Name,20,fp);
	fclose(fp);//close the file
}
